package io.github.lee.jel.repository

import com.google.gson.Gson
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody

open class BaseRepository {


    fun toRequestBody(any: Any, contentType: MediaType? = null): RequestBody {
        val json = Gson().toJson(any)
        return json.toRequestBody(
            contentType ?: "application/json; charset=UTF-8".toMediaTypeOrNull()
        )
    }

}